package dbpopulator;
import java.util.HashMap;
 
/**
 * @author Sadiq Charaniya
 * This table is from the book
 * primary keys are as given in book but foreign keys are different
 * */
public class TestDbTupleGenerator {

	/**
	 * @param args
	 */
	public static void main(String[] args) {

		//HashMap<String, Comparable[][]> resultTest;
		DBTupleGenerator test = new DBTupleGenerator();
		String[] atr = {"Id", "Name", "address","Status"};
		String[] dm = {"Integer","String","String","String"};
		String[] pk = {"Id"};
		String[][] fk =null;
		test.addRelSchema("Student",atr,dm,pk,fk);
		
		String[] atr1 = {"Id", "Name", "DeptId"};
		String[] dm1 = {"Integer","String","String"};
		String[] pk1 = {"Id"};
		String[][] fk1 =null;
		test.addRelSchema("Professor",new String[]{"Id", "Name", "DeptId"},dm1,pk1,fk1);
		
		String[] atr2 = {"CrsCode", "DeptId","CrsName","Descr"};
		String[] dm2 = {"String","String","String","String"};
		String[] pk2 = {"CrsCode"};
		String[][] fk2 =null;
		test.addRelSchema("Course",atr2,dm2,pk2,fk2);
		
		String[] atr3 = {"StudId", "CrsCode","Semester","Grade"};
		String[] dm3 = {"Integer","String","String","String"};
		String[] pk3 = {"StudId","CrsCode","Semester"};
		String[][] fk3 ={{"StudId","Student","Id"},{"CrsCode","Course","CrsCode"}};
		test.addRelSchema("Transcript",atr3,dm3,pk3,fk3);
		
		String[] atr4 = {"ProfId", "CrsCode","Semester"};
		String[] dm4 = {"String","String","String"};
		String[] pk4 = {"CrcCode","Semester"};
		String[][] fk4 ={{"CrsCode","Course","CrsCode"},{"CrsCode Semester","Transcript","CrsCode Semester"}};
		test.addRelSchema("Teaching",atr4,dm4,pk4,fk4);
		
		
		String[] tables = {"Student","Professor","Course","Transcript","Teaching"};
		
		
		
		int tups[] = new int[5];
		tups[0] = 5000;
		tups[1] = 5000;
		tups[2] = 5000;
		tups[3] = 5000;
		tups[4] = 5000;
	
		Comparable[][][] resultTest = test.generate(tups);
		
		for(int i=0;i< resultTest.length;i++){
			
			System.out.println(tables[i]);
			for(int j=0; j< resultTest[i].length;j++){
				for(int k=0; k < resultTest[i][j].length;k++){
					System.out.print(resultTest[i][j][k]+",");
				}
				System.out.println();
			}
			System.out.println();
			
		}
		
	}

}
